package com.example.demo.auth.web;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.auth.service.LoginInfoService;
import com.example.demo.entity.LoginEnity;
import com.example.demo.entity.base.ResponseBean;
import com.example.demo.util.TokenUtil;

@RestController
@RequestMapping(value="/auth/logininfo")
@Deprecated
public class LoginInfoController {
	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private LoginInfoService loginInfoService;
	
	/**
	 * @param request
	 * @param logininfo
	 * @return
	 * @创建时间 2019年6月26日
	 * @创建人 许子文
	 * @功能描述: 添加登陆账户
	 */
	@RequestMapping(value="addloginuser",method=RequestMethod.POST)
	public ResponseBean addLoginUser(HttpServletRequest request,LoginEnity logininfo) {
		
		final String APIDESC = "添加登陆账户";
		
		logger.info("进入{}接口：/auth/logininfo/addloginuser",APIDESC);
		
		ResponseBean ret = loginInfoService.addLoginUser(logininfo);
		
		return ret;		
	}
	
	/**
	 * 查询登陆账户信息
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/getallloginid")
	public ResponseBean getAllLoginId(HttpServletRequest request) {
		
		final String APIDESC = "查询登陆账户信息";
		
		String token = TokenUtil.getTokenFromRequest(request);
		
		logger.info("进入{}接口：/auth/logininfo/getallloginid,token={}",APIDESC,token);
		
		ResponseBean ret = loginInfoService.getAllLoginId();
		
		return ret;
	}
}
